<?php
//命令模式
interface Group{
    public function add();
    public function delete();
    public function find();
    public function plan();
}

class CodeGroup implements Group{

    public function __contruct(){

    }

    public function add()
    {
       echo "code add</br>";
    }

    public function delete()
    {
       echo "code delete</br>";
    }

    public function find()
    {
       echo "code find</br>";
    }

    public function plan()
    {
       echo "code plan</br>";
    }
}
class RequireGroup implements Group{
    public function add()
    {
        echo "require add</br>";
    }

    public function delete()
    {
        echo "require delete</br>";
    }

    public function find()
    {
        echo "require find</br>";
    }

    public function plan()
    {
        echo "require plan</br>";
    }
}

class PageGroup implements Group{
    public function add()
    {
        echo "page add</br>";
    }

    public function delete()
    {
        echo "page delete</br>";
    }

    public function find()
    {
        echo "page find</br>";
    }

    public function plan()
    {
        echo "page plan</br>";
    }
}


abstract class Command{
    protected $requireGroup;
    protected $pageGroup;
    protected $codeGroup;

    public function __construct(){
        $this->requireGroup=new RequireGroup();
        $this->pageGroup=new PageGroup();
        $this->codeGroup=new CodeGroup();
    }

    public abstract function excute();
}

class DeletePageCommand extends Command{

    public function __construct()
    {
        parent::__construct();
    }

    public function excute()
    {
        $this->pageGroup->find();
        $this->pageGroup->delete();
        $this->pageGroup->plan();
    }

}

class AddRequireCommand extends Command{

    public function __construct()
    {
        parent::__construct();
    }

    public function excute()
    {
        $this->requireGroup->find();
        $this->requireGroup->delete();
        $this->requireGroup->plan();
    }

}

class Invoker{
    public $command;
    public function setCommand(Command $command){
        $this->command=$command;
    }

    public function action(){
        $this->command->excute();
    }
}

class Client{
    public $invoker;

    public function __construct(){
        $this->invoker=new Invoker();

        echo "××××××××××××××××××××××××添加一项需求×××××××××××××××××</br>";
        $command1 = new AddRequireCommand();
        $this->invoker->setCommand($command1);
        $this->invoker->action();

        echo "××××××××××××××××××××××××删除一项页面×××××××××××××××××</br>";
        $command2 = new deletePageCommand();
        $this->invoker->setCommand($command2);
        $this->invoker->action();
    }
}

echo "<meta charset=UTF-8>";
new Client();
?>